namespace DmServer.Handlers.Handlers;

public class GetClientSize : IMessageHandler
{
    public void HandleMessage(StringRequestInfo? request, TcpSessionClient client, DmSoft dm)
    {
        if (request?.Parameters == null || request.Parameters.Length != 1)
            client.SendAsync(CryptoHelper.EncryptDES("协议命令错误！"));
        int.TryParse(request?.Parameters?[0], out int hwnd);
        var result = dm.GetClientSize(hwnd, out int width, out int heigh);
        List<int> arrs = new List<int>() { width, heigh };
        string json = arrs.ToJsonString();//序列化

        client.Logger.Info("GetClientSize：" + result.ToString() + "|" + json);
        // 回复客户端消息
        client.SendAsync(CryptoHelper.EncryptDES(json));
    }
}
